home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Adobe / desktop / olwm / acroread.deskinstall < prev    next >
Encoding:
Text File  |  1995-11-01  |  5.5 KB  |  264 lines

  1. #!/bin/sh
  2. # Copyright (c) 1994 by Adobe Systems Incorporated.
  3. #
  4. # vi:set ts=40 sw=2:
  5. #
  6. # Shell script for integrating Acrobat with OpenWindow desktop.
  7. #
  8. ###################################################################
  9.  
  10. cmd=acroread
  11. ver=2.1
  12.  
  13. pdf_icon="pdf.icon"
  14. app_icon="$cmd.prog.icon"
  15. our_cetable="$cmd.cetable"
  16. cetable_orig="/tmp/orig.cetable.$$"
  17. cetable_file="/tmp/new.cetable.$$"
  18. checkstring="<${cmd}-prog>"
  19.  
  20.  
  21. #
  22. # Tests the version file in an installation directory.
  23. #
  24. test_install_dir()
  25. {
  26.   if [ "$1" -a -f "$1/AcroVersion" ] \
  27.   && [ "`cat $1/AcroVersion 2>/dev/null`" = "$ver" ] ; then
  28.     return 0
  29.   else
  30.     return 1
  31.   fi
  32. }
  33.  
  34.  
  35. #
  36. # Make sure openwin stuff is on user's path so ce_db_merge can be found
  37. #
  38. if [ "$OPENWINHOME" = "" ] ; then
  39.   OPENWINHOME=/usr/openwin
  40.   export OPENWINHOME
  41. fi
  42. PATH="/usr/bin:$PATH:$OPENWINHOME/bin"
  43. export PATH
  44.  
  45.  
  46. #
  47. # Process command line args, set mergetype
  48. #
  49. if [ $# = 0 ] ; then
  50.   if [ -x "/usr/ucb/whoami" ] ; then
  51.     whoami="`/usr/ucb/whoami`"
  52.   else
  53.     whoami="`id | sed 's/^[^(]*(\([^)]*\)).*$/\1/'`"
  54.   fi
  55.  
  56.   if [ "$whoami" = "root" ] ; then
  57.     mergetype=system
  58.   else
  59.     mergetype=user
  60.   fi
  61. elif [ $# = 1 ] ; then
  62.   if [ "$1" = "-user" ] ; then
  63.     mergetype=user
  64.   elif [ "$1" = "-system" ] ; then
  65.     mergetype=system
  66.   elif [ "$1" = "-network" ] ; then
  67.     mergetype=network
  68.   else
  69.     echo "Usage: $0 [ -user | -system | -network ]"
  70.     exit 1
  71.   fi
  72. else
  73.   echo "Usage: $0 [ -user | -system | -network ]"
  74.   exit 1
  75. fi
  76.  
  77.  
  78. #
  79. # Setup ACRO_ARG0 to this script
  80. #
  81. arg0="$0"
  82. if [ "$arg0" ] ; then
  83.   case "$arg0" in
  84.      /*) ;;
  85.     ./*) arg0="`pwd`/`expr "$arg0" : '\./\(.*\)'`" ;;
  86.       *) arg0="`pwd`/$arg0" ;;
  87.   esac
  88.  
  89.   ACRO_ARG0="$arg0"
  90.   export ACRO_ARG0
  91. fi
  92.  
  93.  
  94. #
  95. # Try to find the installation directory
  96. #
  97. if ( test_install_dir "$install_dir" ) ; then
  98.   ACRO_INSTALL_DIR="$install_dir"
  99.   export ACRO_INSTALL_DIR
  100. else
  101.   script="$arg0"
  102.   while [ "$script" ] ; do
  103.     install_dir="`dirname "$script"`"
  104.     if ( test_install_dir "$install_dir" ) ; then
  105.       ACRO_INSTALL_DIR="$install_dir"
  106.       export ACRO_INSTALL_DIR
  107.       break
  108.     fi
  109.  
  110.     install_dir="`dirname "$install_dir"`"
  111.     if ( test_install_dir "$install_dir" ) ; then
  112.       ACRO_INSTALL_DIR="$install_dir"
  113.       export ACRO_INSTALL_DIR
  114.       break
  115.     fi
  116.  
  117.     install_dir="`dirname "$install_dir"`"
  118.     if ( test_install_dir "$install_dir" ) ; then
  119.       ACRO_INSTALL_DIR="$install_dir"
  120.       export ACRO_INSTALL_DIR
  121.       break
  122.     fi
  123.  
  124.     if [ -h "$script" ] ; then
  125.       new_script=`ls -l "$script" | sed 's/^.*-> *\(.*\) *$/\1/'`
  126.       if [ "$new_script" -a "`expr "$new_script" : '/.*'`" = 0 ] ; then
  127.         new_script="`dirname "$script"`/$new_script"
  128.       fi
  129.       script="$new_script"
  130.     else
  131.       break
  132.     fi
  133.   done
  134.  
  135.   if ( test_install_dir "$ACRO_INSTALL_DIR" ) ; then
  136.     :
  137.   elif ( test_install_dir "$ACRO_HOME" ) ; then
  138.     ACRO_INSTALL_DIR="$ACRO_HOME"
  139.     export ACRO_INSTALL_DIR
  140.   else
  141.     echo "ERROR: Cannot find installation directory."
  142.     exit 1
  143.   fi
  144. fi
  145.  
  146.  
  147. #
  148. # Check for icon files
  149. #
  150. if [ ! -r "$ACRO_INSTALL_DIR/desktop/olwm/$pdf_icon" \
  151.   -o ! -r "$ACRO_INSTALL_DIR/desktop/olwm/$app_icon" \
  152.   -o ! -r "$ACRO_INSTALL_DIR/desktop/olwm/$our_cetable" ]
  153. then
  154.   echo "ERROR: olwm files missing?"
  155. fi
  156.  
  157.  
  158. #
  159. # Check for ce_db commands
  160. #
  161. if [ "`type ce_db_build`" = "ce_db_build not found" ] ; then
  162.   echo "ERROR: Unable to find ce_db_build program."
  163.   exit 1
  164. fi
  165. if [ "`type ce_db_merge`" = "ce_db_merge not found" ] ; then
  166.   echo "ERROR: Unable to find ce_db_merge program."
  167.   exit 1
  168. fi
  169.  
  170.  
  171. #
  172. # Determine if database already exists.
  173. #
  174. if ce_db_build $mergetype -to_ascii "$cetable_orig" >/dev/null 2>&1 ; then
  175.   ce_cmd=ce_db_merge
  176.   if grep "$checkstring" "$cetable_orig" >/dev/null 2>&1 ; then
  177.     echo ""
  178.     echo "Icons appear to be already integrated into your desktop."
  179.     echo ""
  180.     echo "If you find that the icons do not appear or work properly,"
  181.     echo "you might want to run binder to remove the old icons and"
  182.     echo "then rerun $0 to install new icons."
  183.     echo ""
  184.     rm -f "$cetable_orig"
  185.     exit 0
  186.   fi
  187. else
  188.   ce_cmd=ce_db_build
  189. fi
  190. rm -f "$cetable_orig"
  191.  
  192.  
  193. #
  194. # Set CE_DIR based on $mergetype
  195. #
  196. if [ "$mergetype" = "user" ] ; then
  197.   CE_DIR=$HOME/.cetables
  198. elif [ "$mergetype" = "system" ] ; then
  199.   CE_DIR=/etc/cetables
  200. elif [ "$mergetype" = "network" ] ; then
  201.   CE_DIR=$OPENWINHOME/include/images
  202. else
  203.   echo "ERROR: Invalid mergetype: $mergetype. Exiting."
  204.   exit 1
  205. fi
  206.  
  207.  
  208. #
  209. # Create directory, if necessary.
  210. #
  211. if [ ! -d "$CE_DIR" ] ; then
  212.   mkdir -p "$CE_DIR"
  213.   if [ $? != 0 ] ; then
  214.     echo "ERROR: Cannot create directory $CE_DIR"
  215.     exit 1
  216.   fi
  217. fi
  218.  
  219.  
  220. #
  221. # Copy icon files into the appropriate place.
  222. #
  223. cp "$ACRO_INSTALL_DIR/desktop/olwm/$pdf_icon" "$CE_DIR"
  224. if [ $? != 0 ] ; then
  225.   echo "ERROR: Unable to copy icon $pdf_icon into $CE_DIR."
  226.   exit 1
  227. fi
  228. cp "$ACRO_INSTALL_DIR/desktop/olwm/$app_icon" "$CE_DIR"
  229. if [ $? != 0 ] ; then
  230.   echo "ERROR: Unable to copy icon $app_icon into $CE_DIR."
  231.   exit 1
  232. fi
  233.  
  234.  
  235. #
  236. # Copy cetable file to /tmp, replacing $ICONDIR with $CE_DIR.
  237. #
  238. rm -f "$cetable_file"
  239. cat "$ACRO_INSTALL_DIR/desktop/olwm/$our_cetable" | \
  240.   sed "s%\$ICONDIR%$CE_DIR%" > "$cetable_file"
  241.  
  242.  
  243. #
  244. # Integrate into OpenWindows Desktop
  245. #
  246. "$ce_cmd" $mergetype -from_ascii "$cetable_file" >/dev/null 2>&1
  247. if [ $? != 0 ] ; then
  248.   echo ""
  249.   echo "Command $ce_cmd failed."
  250.   echo "Installation onto the OpenWindows desktop failed...exiting."
  251.   echo "You may need to install icons manually using the OpenWindows binder program."
  252.   rm -f "$cetable_file"
  253.   exit 1
  254. fi
  255. rm -f "$cetable_file"
  256.  
  257.  
  258. #
  259. # All done
  260. #
  261. echo "Integration with OpenWindows desktop completed."
  262. exit 0
  263.  
  264.